<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>课程管理</title>
</head>
<body>

<div th:include="main :: head"></div>


<h1 style="display: flex;justify-content: space-around">课程管理</h1>

<div style="display: flex;justify-content: space-around">


    <div style="display: flex;justify-content: space-around">

        <div>

            <table border="1">  <!-- 分页查询 -->
                <tr th:each="x:${courses}">
                    <td th:text="${x.cno}"></td>
                    <td th:text="${x.cname}"></td>
                    <td ><a th:href="'/adm/course/go2update?cno='+ ${x.cno}">更改课程名称</a></td>
                    <td ><a th:href="'/adm/course/del?cno='+ ${x.cno}">删除该课程</a></td>
                </tr>
            </table>

            <a th:href="'/adm/course/prevpage?curpage='+${curpage}">上一页</a>
            <a th:text="${curpage}"></a> / <a th:text="${page}"></a>
            <a th:href="'/adm/course/nextpage?curpage='+${curpage}">下一页</a>

        </div>

    </div>

    <div style="display: flex;justify-content: space-around">


        <div>

            <button><a href="/adm/course/show">显示所有课程</a></button>

            <button><a href="/adm/course/go2add">添加一个新的课程</a></button>




            <div th:if="${action=='add'}">   <!-- 显示 ： 添加课程  -->
            <h2 th:text="${actmsg}"></h2>
            </div>

            <div th:if="${action=='update'}">   <!-- 显示 ： 修改课程  -->
            <h2 th:text="${actmsg}"></h2>
            </div>



            <div th:if="${action=='add'}">  <!-- 添加 -->

            <form th:action="'/adm/course/'+${action}" method="post">

            课程编号：<input type="text" name="cno"><br>
            课程名称：<input type="text" name="cname"><br>
            <input type="submit" th:value="${actmsg}">

            </form>

            </div>


            <div th:if="${action=='update'}">  <!-- 修改 -->

            <form th:action="'/adm/course/'+${action}" method="post">

            课程编号：<input type="text" name="cno" th:value="${course.cno}"><br>
            课程名称：<input type="text" name="cname" th:value="${course.cname}"><br>
            <input type="submit" th:value="${actmsg}">

            </form>
            </div>

        </div>

    </div>

</div>

</body>
</html>

